﻿<?php
//------- INIT

require_once("include.php");

//------- DATA VERIFICATION


//------- LOGIC
$name; // name of the event
$startDate; // Start date and time of the event
$endDate; // End date and time of the event
$location; // Location of the event
$description; // description of the event

//Arrays of which chars that should be replaced with what
$search = array('<', '>');
$replace = array('&lt;', '&gt;');

//Check if the fields of the form is filled and with what
if($_POST['name']){
	$name = (str_replace($search, $replace, $_POST['name']);
}
if($_POST['startDate']){
	$startDate = (str_replace($search, $replace, $_POST['startDate']);
}
if($_POST['endDate']){
	$endDate = (str_replace($search, $replace, $_POST['endDate']);
}
if($_POST['location']){
	$location = (str_replace($search, $replace, $_POST['location']);
}
if($_POST['description']){
	$description = (str_replace($search, $replace, $_POST['description']);
}

if(!$_POST['name'] || !$_POST['StartDate'] || !$_POST['endDate'] || !$_POST['location'] || !$_POST['description']){
	echo "Du har ikke udfyldt alle felter!"
}



//------- HTML
?>
<html>
<body>
<h1>Opret et nyt arrangement</h1>
<form action="createEvent.php" method="post">
	Titel:<br />
	<input type="text" name="name" value=" <?php echo $name; ?>" /><br />
	Startdato og -tid:<br />
	<input type="text" name="startDate" value=" <?php echo $startDate; ?>" /><br />
	Slutdato og -tid:<br />
	<input type="text" name="endDate" value=" <?php echo $endDate; ?>" /><br />
	Sted:<br />
	<input type="text" name="location" value=" <?php echo $location; ?>" /><br />
	Beskrivelse:<br />
	<textarea rows="5" cols="20" wrap="physical" name="description"><?php echo $description; ?></textarea><br />
	<input type="submit" value="Opret" />
</form>
</body>
</html>